function customerChoice(btn) {

    const choice = document.querySelectorAll(".selectForm");
    choice.forEach(l => l.classList.remove("cursel"));
    btn.classList.add("cursel");
    document.getElementById("firsttable").classList.remove("noshow");
    document.getElementById("secondtable").classList.add("noshow");
    document.getElementById("thirdtable").classList.add("noshow");


}


function bankNumChoice(btn) {
    const choice = document.querySelectorAll(".selectForm");
    choice.forEach(l => l.classList.remove("cursel"));
    btn.classList.add("cursel");

    document.getElementById("firsttable").classList.add("noshow");
    document.getElementById("secondtable").classList.remove("noshow");
    document.getElementById("thirdtable").classList.add("noshow");

}

function competitorChoice(btn) {
    const choice = document.querySelectorAll(".selectForm");
    choice.forEach(l => l.classList.remove("cursel"));
    btn.classList.add("cursel");

    document.getElementById("firsttable").classList.add("noshow");
    document.getElementById("secondtable").classList.add("noshow");
    document.getElementById("thirdtable").classList.remove("noshow");
}

function searchFor() {

    let text = document.getElementById("textSearch").value;
    console
    if (isEmpty(text)) {
        alert("请输入所要查询的客户")
        return;
    }

    let table = document.getElementById("mainform");
    let tr1 = table.rows;
    let trlength = tr1.length
    for (let i = 1; i < trlength; i++) {
        let tr = tr1[1];
        table.deleteRow(tr.rowIndex);
    }

    let url = "http://localhost:8080/CustomersForm/select"
    $.ajax({
        type: "post",
        url: url,
        traditional: true,
        data: {
            text: text
        },
        success: function (data) {
            //传入成功时的操作
            alert("查询结果如下");

            let result = JSON.parse(data);

            let forms = []

            console.log(result.length);
            for (let i = 0; i < result.length; i++) {
                let id = result[i].id;
                console.log(id);

                let name = result[i].name;
                let unit = result[i].unit;
                let classify = result[i].classify;
                let source = result[i].source;
                let cus_address = result[i].cus_address;
                let serve = result[i].serve;
                let servetype = result[i].servetype;
                let address = result[i].address;
                let level = result[i].level;
                let division_code = result[i].division_code;
                let zip_code = result[i].zip_code;
                let shortname = result[i].shortname;
                let j_person = result[i].j_person;
                let organization = result[i].organization;
                let web = result[i].web;
                let status = result[i].status;
                let phone = result[i].phone;

                let mainForm = {
                    id: id,
                    name: name,
                    unit: unit,
                    classify: classify,
                    source: source,
                    serve: serve,
                    servetype: servetype,
                    cus_address: cus_address,
                    address: address,
                    level: level,
                    division_code: division_code,
                    zip_code: zip_code,
                    shortname: shortname,
                    j_person: j_person,
                    organization: organization,
                    web: web,
                    status: status,
                    phone: phone,
                }
                forms.push(mainForm);
            }

            // console.log("mainforms:"+forms.length);
            // for(var i=0;i<forms.length;i++){
            //     console.log(forms[i].id);
            //     console.log(forms[i].phone);
            // }
            let tb = document.getElementById("mainform");
            for (var i = 0; i < forms.length; i++) {
                let tr = document.createElement("tr");
                tb.appendChild(tr);
                tr.innerHTML = "<td><input class='contactForm' type='button' value='查看' onclick='showContactForm(this)'></td>" +
                    "<td><input class='contactForm' type='button' value='编辑' onclick='editForm(this)'></td>" +
                    "<td><input class='contactForm' type='button' value='删除' onclick='deleteContact(this)'></td>"+
                    "                    <td>" + forms[i].id + "</td>\n" +
                    "                    <td>" + forms[i].name + "</td>\n" +
                    "                    <td>" + forms[i].unit + "</td>\n" +
                    "                    <td>" + forms[i].classify + "</td>\n" +
                    "                    <td>" + forms[i].source + "</td>\n" +
                    "                    <td>" + forms[i].serve + "</td>\n" +
                    "                    <td>" + forms[i].servetype + "</td>\n" +
                    "                    <td>" + forms[i].cus_address + "</td>\n" +
                    "                    <td>" + forms[i].address + "</td>\n" +
                    "                    <td>" + forms[i].level + "</td>\n" +
                    "                    <td>" + forms[i].division_code + "</td>\n" +
                    "                    <td>" + forms[i].zip_code + "</td>\n" +
                    "                    <td>" + forms[i].shortname + "</td>\n" +
                    "                    <td>" + forms[i].j_person + "</td>\n" +
                    "                    <td>" + forms[i].organization + "</td>\n" +
                    "                    <td>" + forms[i].web + "</td>\n" +
                    "                    <td>" + forms[i].status + "</td>" +
                    "                    <td>" + forms[i].phone + "</td>\n";
            }

        },
        error: function (jqXHR, textStatus, errorThrown) {
            //传入失败时的操作
            alert("查询失败");
        }
    })


}

function searchForAll() {
    let table = document.getElementById("mainform");
    let tr1 = table.rows;
    let trlength = tr1.length
    for (let i = 1; i < trlength; i++) {
        let tr = tr1[1];
        table.deleteRow(tr.rowIndex);
    }
    let url = "http://localhost:8080/CustomersForm/selectAll"
    $.ajax({
        type: "post",
        url: url,
        traditional: true,
        data: {},
        success: function (data) {
            //传入成功时的操作

            // data.each({
            //
            // })


            alert("查询结果如下");
            let result = JSON.parse(data);
            // console.log("111111111111");
            // console.log("parse:"+result);
            // console.log("forms: "+data.formjson);
            let forms = []

            for (let i = 0; i < result.length; i++) {
                let id = result[i].id;
                let name = result[i].name;
                let unit = result[i].unit;
                let classify = result[i].classify;
                let source = result[i].source;
                let cus_address = result[i].cus_address;
                let serve = result[i].serve;
                let servetype = result[i].servetype;
                let address = result[i].address;
                let level = result[i].level;
                let division_code = result[i].division_code;
                let zip_code = result[i].zip_code;
                let shortname = result[i].shortname;
                let j_person = result[i].j_person;
                let organization = result[i].organization;
                let web = result[i].web;
                let status = result[i].status;
                let phone = result[i].phone;

                let mainForm = {
                    id: id,
                    name: name,
                    unit: unit,
                    classify: classify,
                    source: source,
                    serve: serve,
                    servetype: servetype,
                    cus_address: cus_address,
                    address: address,
                    level: level,
                    division_code: division_code,
                    zip_code: zip_code,
                    shortname: shortname,
                    j_person: j_person,
                    organization: organization,
                    web: web,
                    status: status,
                    phone: phone,
                }
                forms.push(mainForm);
            }

            // console.log("mainforms:"+forms.length);
            // for(var i=0;i<forms.length;i++){
            //     console.log(forms[i].id);
            //     console.log(forms[i].phone);
            // }
            let tb = document.getElementById("mainform");
            for (var i = 0; i < forms.length; i++) {
                let tr = document.createElement("tr");
                tb.appendChild(tr);
                tr.innerHTML = "<td><input class='contactForm' type='button' value='查看' onclick='showContactForm(this)'></td>" +
                    "<td><input class='contactForm' type='button' value='编辑' onclick='editForm(this)'></td>" +
                    "<td><input class='contactForm' type='button' value='删除' onclick='deleteContact(this)'></td>"+
                    "                    <td>" + forms[i].id + "</td>\n" +
                    "                    <td>" + forms[i].name + "</td>\n" +
                    "                    <td>" + forms[i].unit + "</td>\n" +
                    "                    <td>" + forms[i].classify + "</td>\n" +
                    "                    <td>" + forms[i].source + "</td>\n" +
                    "                    <td>" + forms[i].serve + "</td>\n" +
                    "                    <td>" + forms[i].servetype + "</td>\n" +
                    "                    <td>" + forms[i].cus_address + "</td>\n" +
                    "                    <td>" + forms[i].address + "</td>\n" +
                    "                    <td>" + forms[i].level + "</td>\n" +
                    "                    <td>" + forms[i].division_code + "</td>\n" +
                    "                    <td>" + forms[i].zip_code + "</td>\n" +
                    "                    <td>" + forms[i].shortname + "</td>\n" +
                    "                    <td>" + forms[i].j_person + "</td>\n" +
                    "                    <td>" + forms[i].organization + "</td>\n" +
                    "                    <td>" + forms[i].web + "</td>\n" +
                    "                    <td>" + forms[i].status + "</td>" +
                    "                    <td>" + forms[i].phone + "</td>\n";
            }

        },
        error: function (jqXHR, textStatus, errorThrown) {
            //传入失败时的操作
            alert("查询失败");
        }
    })

}

function showContactForm(btn) {
    document.getElementById("searchresult").classList.add("noshow");
    document.getElementById("contactShow").classList.remove("noshow");

    let tb = btn.parentNode.parentNode;
    let id = tb.cells[3].innerHTML
    document.getElementById("contactParent").children[0].innerHTML = id
    let url = "http://localhost:8080/CustomersForm/contactForm"
    $.ajax({
        type: "post",
        url: url,
        traditional: true,
        data: {
            id: id
        },
        success: function (data) {

            let table = document.getElementById("firsttable");
            let tr1 = table.rows;
            let trlength = tr1.length
            for (let i = 1; i < trlength; i++) {
                let tr = tr1[1];
                table.deleteRow(tr.rowIndex);
            }

            alert("结果如下");
            let result = JSON.parse(data);
            let forms = []
            for (let i = 0; i < result.length; i++) {
                let id = result[i].id;
                let name = result[i].name;
                let department = result[i].department;
                let posts = result[i].posts;
                let phone = result[i].phone;
                let personnel = result[i].personnel;
                let recenttime = result[i].recenttime;
                let wechat = result[i].wechat;
                let qq = result[i].qq;

                let mainForm = {
                    id: id,
                    name: name,
                    department: department,
                    posts: posts,
                    phone: phone,
                    personnel: personnel,
                    recenttime: recenttime,
                    wechat: wechat,
                    qq: qq,
                }
                forms.push(mainForm);
            }


            let tb = document.getElementById("firsttable");
            for (var i = 0; i < forms.length; i++) {
                let tr = document.createElement("tr");
                tb.appendChild(tr);
                tr.innerHTML = "<td><input class='contactForm' type='button' value='编辑' onclick='editContactForm(this)'></td>" +
                    "<td><input class='contactForm' type='button' value='删除' onclick='deleteCustomer(this)'></td>" +
                    "          <td>" + forms[i].id + "</td>\n" +
                    "                    <td>" + forms[i].name + "</td>\n" +
                    "                    <td>" + forms[i].department + "</td>\n" +
                    "                    <td>" + forms[i].posts + "</td>\n" +
                    "                    <td>" + forms[i].phone + "</td>\n" +
                    "                    <td>" + forms[i].personnel + "</td>\n" +
                    "                    <td>" + forms[i].recenttime + "</td>\n" +
                    "                    <td>" + forms[i].wechat + "</td>\n" +
                    "                    <td>" + forms[i].qq + "</td>";
            }
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("查询失败");
        }
    })
}

function showCustomerForm() {
    document.getElementById("searchresult").classList.remove("noshow");
    document.getElementById("contactShow").classList.add("noshow");

}

function editForm(btn) {
    let tr = btn.parentNode.parentNode;
    let cell = tr.cells[1];
    cell.innerHTML = "<input class='contactForm' type='button' value='保存' onclick='saveEdition(this)'>"
    console.log("tr:" + tr)
    console.log("trl:" + tr.cells.length)
    for (let i = 4; i < tr.cells.length; i++) {
        cell = tr.cells[i];
        cell.innerHTML = "<input type ='text' class='editInput' value=' " + cell.innerHTML + "' />"
    }
}

function saveEdition(btn) {

    //判断输入的内容是否合法
    let tr = btn.parentNode.parentNode;
    for (let i = 4; i < tr.cells.length-8; i++) {

        if(i!= 10 && isEmpty(tr.cells[i].children[0].value)){
            tr.cells[i].children[0].style.borderColor = "red";
            tr.cells[i].children[0].setAttribute("placeholder","此处不能为空");
            return;
        }
        else{
            tr.cells[i].children[0].style.borderColor = "";
        }
    }


    //保存并提交表单
    let cell = tr.cells[1];
    cell.innerHTML = "<input class='contactForm' type='button' value='编辑' onclick='editForm(this)'>";
    for (let i = 4; i < tr.cells.length; i++) {
        cell = tr.cells[i];
        cell.innerHTML = cell.childNodes[0].value;
    }

    let id = tr.cells[3].innerHTML;
    let name = tr.cells[4].innerHTML;
    let unit = tr.cells[5].innerHTML;
    let classify = tr.cells[6].innerHTML;
    let source = tr.cells[7].innerHTML;
    let cus_address = tr.cells[8].innerHTML;
    let serve = tr.cells[9].innerHTML;
    let servetype = tr.cells[10].innerHTML;
    let address = tr.cells[11].innerHTML;
    let level = tr.cells[12].innerHTML;
    let division_code = tr.cells[13].innerHTML;
    let zip_code = tr.cells[14].innerHTML;
    let shortname = tr.cells[15].innerHTML;
    let j_person = tr.cells[16].innerHTML;
    let organization = tr.cells[17].innerHTML;
    let web = tr.cells[18].innerHTML;
    let status = tr.cells[19].innerHTML;
    let phone = tr.cells[20].innerHTML;

    form = {
        id: id,
        name: name,
        unit: unit,
        classify: classify,
        source: source,
        cus_address: cus_address,
        serve: serve,
        servetype: servetype,
        address: address,
        level: level,
        division_code: division_code,
        zip_code: zip_code,
        shortname: shortname,
        j_person: j_person,
        organization: organization,
        web: web,
        status: status,
        phone: phone
    }

    let url = "http://localhost:8080/CustomersForm/editForm"
    $.ajax({
        type: "post",
        url: url,
        traditional: true,
        data: {
            MainForm: JSON.stringify(form)
        },
        success: function (data) {
            alert("修改成功");
        },
        error: function () {
            alert("修改失败");
        }
    })

}

function editContactForm(btn) {
    let tr = btn.parentNode.parentNode;
    let cell = tr.cells[0];
    cell.innerHTML = "<input class='contactForm' type='button' value='保存' onclick='saveContactEdition(this)'>"
    for (let i = 3; i < tr.cells.length; i++) {
        cell = tr.cells[i];
        cell.innerHTML = "<input type ='text' class='editInput' value='" + cell.innerHTML + "' />"
    }
}

function saveContactEdition(btn) {

    let tr = btn.parentNode.parentNode;

    //判断输入内容是否合法
    for (let i = 3; i < tr.cells.length-2; i++) {

        console.log("value:"+tr.cells[i].children[0].value)
        if(isEmpty(tr.cells[i].children[0].value)){
            tr.cells[i].children[0].style.borderColor = "red";
            tr.cells[i].children[0].setAttribute("placeholder","此处不能为空");
            return;
        }
        else{
            tr.cells[i].children[0].style.borderColor = "";
        }
    }
    if(isNaN(Number(tr.cells[6].children[0].value))){
        tr.cells[6].children[0].style.borderColor = "red";
        tr.cells[6].children[0].setAttribute("placeholder","此处为数字");
        alert("请输入合法的客户联系人号码");
        return;
    }


    //保存并提交表单
    let cell = tr.cells[0];
    cell.innerHTML = "<input class='contactForm' type='button' value='编辑' onclick='editContactForm(this)'>";
    for (let i = 3; i < tr.cells.length; i++) {
        cell = tr.cells[i];
        cell.innerHTML = cell.childNodes[0].value;
    }

    let id = tr.cells[2].innerHTML;
    let name = tr.cells[3].innerHTML;
    let department = tr.cells[4].innerHTML;
    let posts = tr.cells[5].innerHTML;
    let phone = tr.cells[6].innerHTML;
    let personnel = tr.cells[7].innerHTML;
    let recenttime = tr.cells[8].innerHTML;
    let wechat = tr.cells[9].innerHTML;
    let qq = tr.cells[10].innerHTML;

    contact = {
        id: id,
        name: name,
        department: department,
        posts: posts,
        phone: phone,
        personnel: personnel,
        recenttime: recenttime,
        wechat: wechat,
        qq: qq
    }

    let url = "http://localhost:8080/CustomersForm/editContactForm"
    $.ajax({
        type: "post",
        url: url,
        traditional: true,
        data: {
            Contact: JSON.stringify(contact)
        },
        success: function (data) {
            alert("修改成功");
        },
        error: function () {
            alert("修改失败");
        }
    })

}


function isEmpty(str) {
    if (str == null || str.trim(str) == "") {
        return true;
    }
    return false;

}

function addCustomer() {
    let tb = document.getElementById("mainform");
    let tr = document.createElement("tr");
    tb.appendChild(tr);
    tr.innerHTML = "<td>#</td>" +
        "<td><input class='contactForm' type='button' value='保存' onclick='saveAddition(this)'></td>" +
        "<td><input class='contactForm' type='button' value='取消' onclick='cancelCustomerAdd(this)'></td>" +
        "                    <td>#</td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n";

}

function saveAddition(btn) {
    let table = btn.parentNode.parentNode;

    let name = table.cells[4].children[0].value;
    table.cells[4].innerHTML = name;
    let unit = table.cells[5].children[0].value;
    table.cells[5].innerHTML = unit;
    let classify = table.cells[6].children[0].value;
    table.cells[6].innerHTML = classify;
    let source = table.cells[7].children[0].value;
    table.cells[7].innerHTML = source;
    let serve = table.cells[8].children[0].value;
    table.cells[8].innerHTML = serve;
    let servetype = table.cells[9].children[0].value;
    table.cells[9].innerHTML = servetype;
    let cus_address = table.cells[10].children[0].value;
    table.cells[10].innerHTML = cus_address;
    let level = table.cells[11].children[0].value;
    table.cells[11].innerHTML = level;
    let division_code = table.cells[12].children[0].value;
    table.cells[12].innerHTML = division_code;
    let zip_code = table.cells[13].children[0].value;
    table.cells[13].innerHTML = zip_code;
    let shortname = table.cells[14].children[0].value;
    table.cells[14].innerHTML = shortname;
    let j_person = table.cells[15].children[0].value;
    table.cells[15].innerHTML = j_person;
    let organization = table.cells[16].children[0].value;
    table.cells[16].innerHTML = organization;
    let web = table.cells[17].children[0].value;
    table.cells[17].innerHTML = web;
    let status = table.cells[18].children[0].value;
    table.cells[18].innerHTML = status;
    let phone = table.cells[19].children[0].value;
    table.cells[19].innerHTML = phone;
    let address = table.cells[20].children[0].value;
    table.cells[20].innerHTML = address;


    let mainForm = {
        id: null,
        name: name,
        unit: unit,
        classify: classify,
        source: source,
        serve: serve,
        servetype: servetype,
        cus_address: cus_address,
        address: address,
        level: level,
        division_code: division_code,
        zip_code: zip_code,
        shortname: shortname,
        j_person: j_person,
        organization: organization,
        web: web,
        status: status,
        phone: phone,
    }

    let url = "http://localhost:8080/CustomersForm/FormUpdate"

    $.ajax({
        type: "post",
        url: url,
        traditional: true,
        data: {
            Mainform: JSON.stringify(mainForm)
        },
        success: function (data) {
            //传入成功时的操作
            alert("表单提交成功");
            let id = JSON.parse(data);
            table.cells[3].innerHTML = id;
            table.cells[0].innerHTML = "<input class='contactForm' type='button' value='查看' onclick='showContactForm(this)'>";
            table.cells[1].innerHTML = "<input class='contactForm' type='button' value='编辑' onclick='editForm(this)'>";
            table.cells[2].innerHTML = "<input class='contactForm' type='button' value='删除' onclick='deleteContact(this)'>";
        },
        error: function (jqXHR, textStatus, errorThrown) {
            //传入失败时的操作
            alert("表单提交失败");
        }
    })
}

function addContact() {
    let tb = document.getElementById("firsttable");
    let tr = document.createElement("tr");
    tb.appendChild(tr);
    tr.innerHTML = "<td><input class='contactForm' type='button' value='保存' onclick='saveContactAddition(this)'></td>" +
        "<td><input class='contactForm' type='button' value='取消' onclick='cancelContactAdd(this)'></td>" +
        "                    <td>#</td>\n" +
        "                    <td><input type ='text' class='editInput nonull' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput nonull' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput nonull' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput isnum' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput nonull' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput nonull' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n" +
        "                    <td><input type ='text' class='editInput' value='' /></td>\n";
}


function saveContactAddition(btn) {
    let table = btn.parentNode.parentNode;
    let dept_id = document.getElementById("contactParent").children[0].innerHTML;

    let name = table.cells[3].children[0].value;
    table.cells[3].innerHTML = name;
    let department = table.cells[4].children[0].value;
    table.cells[4].innerHTML = department;
    let posts = table.cells[5].children[0].value;
    table.cells[5].innerHTML = posts;
    let phone = table.cells[6].children[0].value;
    table.cells[6].innerHTML = phone;
    let personnel = table.cells[7].children[0].value;
    table.cells[7].innerHTML = personnel;
    let recenttime = table.cells[8].children[0].value;
    table.cells[8].innerHTML = recenttime;
    let wechat = table.cells[9].children[0].value;
    table.cells[9].innerHTML = wechat;
    let qq = table.cells[10].children[0].value;
    table.cells[10].innerHTML = qq;


    let customer = {
        id: null,
        name: name,
        department: department,
        posts: posts,
        phone: phone,
        personnel: personnel,
        recenttime: recenttime,
        wechat: wechat,
        qq: qq,
        dept_id: dept_id
    }

    console.log("customer:"+customer);
    let url = "http://localhost:8080/CustomersForm/ContactUpdate"

    $.ajax({
        type: "post",
        url: url,
        traditional: true,
        data: {
            Customer: JSON.stringify(customer)
        },
        success: function (data) {
            //传入成功时的操作
            alert("表单提交成功");
            let id = JSON.parse(data);
            table.cells[2].innerHTML = id;
            table.cells[0].innerHTML = "<input class='contactForm' type='button' value='编辑' onclick='editContactForm(this)'>";
            table.cells[1].innerHTML = "<input class='contactForm' type='button' value='删除' onclick='deleteCustomer(this)'>";
        },
        error: function (jqXHR, textStatus, errorThrown) {
            //传入失败时的操作
            alert("表单提交失败");
        }
    })
}

function cancelCustomerAdd(btn) {
    let tb = document.getElementById("mainform");
    let tr = btn.parentNode.parentNode;
    tb.deleteRow(tr.rowIndex);
}

function cancelContactAdd(btn) {
    let tb = document.getElementById("firsttable");
    let tr = btn.parentNode.parentNode;
    tb.deleteRow(tr.rowIndex);
}



function deleteContact(btn) {
    let a =   confirm("是否确认删除");
    if(a == false){
        return;
    }
    let tr = btn.parentNode.parentNode;
    let id = tr.cells[3].innerHTML
    console.log(id);
    let url =  "http://localhost:8080/CustomersForm/deleteCustomer";
    $.ajax({
        type:"post",
        url:url,
        data:{
            deletedId:id
        },
        success:function (data){
            alert("删除成功");
        },
        error:function (){
            alert("删除失败");
        }


    })
    cancelCustomerAdd(btn);
}

function deleteCustomer(btn) {
    let a =   confirm("是否确认删除");
    if(a == false){
        return;
    }
    let tr = btn.parentNode.parentNode;
    let id = tr.cells[2].innerHTML
    console.log(id);
    let url =  "http://localhost:8080/CustomersForm/deleteContact";
    $.ajax({
        type:"post",
        url:url,
        data:{
            deletedId:id
        },
        success:function (data){
            alert("删除成功");
        },
        error:function (){
            alert("删除失败");
        }
    })
    cancelContactAdd(btn);
}